import 'package:flutter/material.dart';

void main() {
  // 1.运行应用程序
  runApp(const MaterialApp(home: Main()));
}

class Main extends StatelessWidget {
  const Main({super.key});

  @override
  Widget build(BuildContext context) {
    // 2.构建应用程序界面
    return Scaffold(
      appBar: AppBar(
        title: const Text(
          'ListView---2.separated用法',
          style: TextStyle(color: Colors.white),
        ),
        backgroundColor: Colors.black,
      ),
      // 中间内容
      body: ListView.separated(
        itemBuilder:(BuildContext context, int index){
          return Container(
            height: 50,
            color: index % 2 == 0 ? const Color.fromARGB(255, 6, 130, 239) : Colors.white,
            child: Text('子元素$index'),
          );
        },
         separatorBuilder:(BuildContext context, int index){
          return Container(
            height: 5,
            color: Colors.grey,
            margin: const EdgeInsets.symmetric(horizontal:10),
          );
        },
        itemCount: 20,

        ),
    );
  }
}
